//可否下拉
var is_bool=true;
// 页码信息
var page_no=1;

$(function() {
    $('.IndexUser').click(function(e){
        location.href=getRootPath()+'/GasHome/Mine/Index?park_id='+$('#park_id').val();
    });

    getGoodsExchangeRecordList() 

    $(window).scroll(function(){
    　　var scrollTop = $(this).scrollTop();
    　　var scrollHeight = $(document).height();
    　　var windowHeight = $(this).height();
    　　if(scrollTop + windowHeight == scrollHeight&&is_bool){
            getGoodsExchangeRecordList();
    　　}
    });

    var IpIntegralRule=document.querySelector('.IpIntegralRule')
    var modle=document.querySelector('.Model')
    IpIntegralRule.index=true
    IpIntegralRule.addEventListener('click',function(e){
        e.stopPropagation();
        if(IpIntegralRule.index){
            modle.className='Model Model-active'
            IpIntegralRule.index=!IpIntegralRule.index
        }else{
            return false
        }
    })
    modle.addEventListener('click',function(){
        if(!IpIntegralRule.index){
            modle.className='Model'
            IpIntegralRule.index=!IpIntegralRule.index
        }else{
            return false
        }
    })
})



function getGoodsExchangeRecordList() {
    //禁止滚动
    is_bool=false;
    
    $('.load').show();
    $.ajax({
        type: "post",
        url: "Api/Goods/getGoodsExchangeRecordList",
        data: {
            park_id: $('#park_id').val(),
            page_no:page_no,
            admin_id:$('#admin_id').val()
        },
        async: true,
        dataType: 'json',
        success: function(data) {
            setTimeout(function(){
                if (data.status) {
                    $('.load').hide();
                    var t=JSON.parse(data.v);
                    $.each(t.data,function(k,v){
                        $('.record-demo a').attr('href',getRootPath()+'/GasHome/Goods/goodsContent?park_id='+$('#park_id').val()+'&goods_id='+v.goods_id);
                        $('.record-demo .goods-name').html('<label>'+(v.goods_name?sub_str(v.goods_name,15):'未知商品')+'</label>  <b>×'+v.num+'</b>');
                        $('.record-demo .exchange-time').html(v.created_char);
                        $('.record-demo .exchange-integral').html(v.integral);
                        $('.record-demo .contact-name').html(v.contact_name);
                        $('.record-demo .contact-phone').html(v.contact_phone);
                        $('.record-demo .contact-address').html(v.contact_address);
                        $('.record-box').append($('.record-demo').html());
                    });
                    is_bool=t.have;
                    page_no++;
                } else {

                }
            },1000);
        }
    });
}

